<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head th:fragment="headcommon">
    <meta charset="UTF-8">
    <script th:src="@{/js/jquery/jquery-3.6.0.js}" type="text/javascript"></script>
    <script th:src="@{/layui/layui.js}" type="text/javascript"></script>
    <script th:src="@{/js/index/index.js}" type="text/javascript"></script>
    <script th:src="@{/js/index/freezeheader.js}" type="text/javascript"></script>
    <script th:src="@{/layui/lay/modules/layer.js}" type="text/javascript"></script>
    <script th:src="@{/js/index/sliders.js}" type="text/javascript"></script>
    <script th:src="@{/js/index/html5.js}" type="text/javascript"></script>
    <link rel="stylesheet" th:href="@{/layui/css/layui.css}" media="all"/>
    <link rel="stylesheet" th:href="@{/layui/css/modules/layer/default/layer.css}"/>
    <link rel="stylesheet" th:href="@{/css/global.css}"/>
</head>
<body>
<div id="top_start" class="layui-header header">
    <div class="main">
        <ul class="layui-nav layui-nav-left" lay-filter="filter">
            <a class="logo" href="#" title="News">News</a>
            <li class="layui-nav-item nav-left">
                <a th:href="@{/index}">首页</a>
            </li>
<!--            <li class="layui-nav-item layui-this">-->
            <li class="layui-nav-item">
                <a href="#">新闻</a>
                <dl class="layui-nav-child">
                    <dd th:each="categrory:${session.cateList}"><a th:href="@{/cate/CateArticle/{id}(id=${categrory.cid})}"
                    th:text="${categrory.cname}">娱乐</a></dd>
                </dl>
            </li>

<!--            <li class="layui-nav-item">-->
<!--                <a th:href="@{/time_line}">公告</a>-->
<!--            </li>-->
            <li class="layui-nav-item" th:if="${session.user ne null && session?.user.lid ge 2} ">
            <a href="#">其他等级用户新闻</a>
            <dl class="layui-nav-child">
                <dd th:if="${session?.user?.lid>1}"><a  th:href="@{/article/other/{lid}(lid=1)}">等级为1</a></dd>
                <dd th:if="${session?.user?.lid>2}"><a  th:href="@{/article/other/{lid}(lid=2)}">等级为2</a></dd>
            </dl>
            </li>
        </ul>

        <ul class="layui-nav layui-layout-right layui-nav-right" lay-filter="filter" th:if="${session.user} eq null">
            <li class="layui-nav-item">
                <a th:href="@{/user/register}">注册</span></a>
            </li>
            <li class="layui-nav-item">
                <a th:href="@{/user/login}">登录</span></a>
            </li>
            <li class="layui-nav-item">
                <a th:href="@{/back/login}">进入后台系统</a>
            </li>

        </ul>
        <ul class="layui-nav layui-layout-right layui-nav-right" lay-filter="filter" th:if="${session.user} ne null">
            <li class="layui-nav-item">
                <a th:href="@{/back/login}">进入后台系统</a>
            </li>

            <li class="layui-nav-item "  >
                <a href="javascript:;" ><img th:src="@{${session.user.headImage}}" class="layui-nav-img" >[[${session.user.newsName}]]</a>
<!--                <a href="javascript:;"><i class="layui-icon" style="font-size: 30px; color: #1E9FFF;" >&#xe66f;</i>[[${session.user.uname}]]</a>-->
                <dl class="layui-nav-child">
                    <dd><a th:href="@{/user/user_center}">用户中心</a></dd>
                    <dd><a th:href="@{/article_pub}">发布新闻</a></dd>
                    <dd><a th:href="@{/user/quit}">退出</a></dd>
                </dl>
            </li>
        </ul>
    </div>
</div>

<!--次级导航-->
<div id="ci_nav" class="ci-nav">
    <script>
        $.get("/common/getCategory", {}, function (data) {
            // 导航
            var lits = ' <li><a href="/index">首页</a></li>';
            var lits = '';
            //遍历数组，拼接字符串
            for (var i = 0; i < data.length; i++) {
                var li = '<a href="/cate/CateArticle/' + data[i].cid + '" class="layui-col-md1 " >' + data[i].cname + '</a>';
                lits += li;
            }
            //将拼接好的字符串，设置到ul中
            $("#cate").html(lits)
                // console.log(data)
        })
    </script>
    <div class="layui-row" id="cate">
<!--        <a href="" class="layui-col-md1">娱乐</a>-->
        这里将会填充从数据库查询到分类信息
    </div>

</div>


<div id="foot_start" class="footer">
    <hr class="layui-bg-red">
    <p><a href="#">新闻发布网站</a> 2022 &copy; <a href="#">The News Release System </a></p>
    <p></p>
    <div></div>
</div>

</body>
</html>